package com.base.system.managedBean;

import java.io.Serializable;

import javax.faces.context.FacesContext;

import org.operamasks.faces.annotation.Action;
import org.operamasks.faces.annotation.BeforeRender;
import org.operamasks.faces.annotation.Inject;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.annotation.SaveState;
import org.operamasks.faces.user.util.Browser;

import com.base.system.managedBean.baseBean.BasePositionBean;

@ManagedBean(name = "system_showPositionBean", scope = ManagedBeanScope.REQUEST)
public class ShowPositionBean extends BasePositionBean implements Serializable {
	@Inject
	private FacesContext context;
	@SaveState
	private String unid;

	// private Position post;

	@BeforeRender
	public void beforeRender(boolean isPostback) {
		if (!isPostback) {
			unid = context.getExternalContext().getRequestParameterMap().get(
					"id");
			if (!"".equals(unid) && null != unid) {
				post = postDao.getById(Integer.valueOf(unid));
			}
			if (post != null) {
				this.getPositonProperty();
			}
		}
	}

	@Action(id = "edit")
	public void edit() {
		String url = context.getExternalContext().getRequestContextPath()
				+ "/modules/system/editPositon.faces?id=" + unid;
		String script = "addCenterLayoutTab('editPositionTab','编辑岗位','" + url
				+ "')";
		Browser.execClientScript("window.top", script);
		Browser.execClientScript("closeCenterLayoutTab('showPositonTab');");
	}
}
